﻿using MongoDB.Bson;
using MongoDB.Bson.Serialization.Attributes;
using System.Collections.Generic;
using System.Linq;

namespace Sustainalytics.BusinessResearchProductStates.Entities.ResearchState
{
    public class PUResearch
    {
        public int PUEncoding { get; set; }

        [BsonRepresentation(BsonType.String)]
        public ResearchState ResearchState { get; set; }

        [BsonRepresentation(BsonType.String)]
        public IEnumerable<ClientFacingProduct> ClientFacingProducts { get; set; }

        public ResearchState GetResearchStateForClientFacingProduct(ClientFacingProduct clientFacingProduct)
            => ClientFacingProducts != null && ClientFacingProducts.Contains(clientFacingProduct) ? ResearchState : ResearchState.ResearchNotAvailable;

        public bool HasResearch { get; set; }
    }
}
